package com.hemerasolutions.v2trainer.model.unit.intensity;

import com.hemerasolutions.v2trainer.model.base.BaseModel;
import com.hemerasolutions.v2trainer.model.unit.volume.VolumeFactor;
import com.hemerasolutions.v2trainer.model.unit.volume.VolumeType;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;

@Entity
public class IntensityUnit extends BaseModel {
 
	private static final long serialVersionUID = 1L;

    @Column
	private int uniqueID;

    @Column(length = 40)
	private String name;
	 
    @Column(length = 40)
    private String description;
	
    @Column
    private int unitType = IU_TYPE_PERFORMANCE;

	@ManyToOne
	private VolumeType volumeType;

	@ManyToOne
	private VolumeFactor volumeFactor;

	
	
    public static int IU_TYPE_PERFORMANCE 	= 0;
    public static int IU_TYPE_SUBJECTIVES 	= 1;
    public static int IU_TYPE_PHYSIOLOGIC 	= 2;
    
    
    public IntensityUnit() {
		super();
	}
    
	public IntensityUnit(int uniqueID,int unitType, String name, String description,
			 VolumeType volumeType, VolumeFactor volumeFactor) {
		super();
		this.uniqueID = uniqueID;
		this.name = name;
		this.description = description;
		this.unitType = unitType;
		this.volumeType = volumeType;
		this.volumeFactor = volumeFactor;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public int getUniqueID() {
		return uniqueID;
	}

	public String getName() {
		return name;
	}

	public String getDescription() {
		return description;
	}

	public void setUniqueID(int uniqueID) {
		this.uniqueID = uniqueID;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getUnitType() {
		return unitType;
	}

	public void setUnitType(int unitType) {
		this.unitType = unitType;
	}

	public VolumeType getVolumeType() {
		return volumeType;
	}

	public void setVolumeType(VolumeType volumeType) {
		this.volumeType = volumeType;
	}

	
	public VolumeFactor getVolumeFactor() {
		return volumeFactor;
	}


	public void setVolumeFactor(VolumeFactor volumeFactor) {
		this.volumeFactor = volumeFactor;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + uniqueID;
		result = prime * result + unitType;
		result = prime * result
				+ ((volumeFactor == null) ? 0 : volumeFactor.hashCode());
		result = prime * result
				+ ((volumeType == null) ? 0 : volumeType.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		IntensityUnit other = (IntensityUnit) obj;
		if (description == null) {
			if (other.description != null) {
				return false;
			}
		} else if (!description.equals(other.description)) {
			return false;
		}
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		if (uniqueID != other.uniqueID) {
			return false;
		}
		if (unitType != other.unitType) {
			return false;
		}
		if (volumeFactor == null) {
			if (other.volumeFactor != null) {
				return false;
			}
		} else if (!volumeFactor.equals(other.volumeFactor)) {
			return false;
		}
		if (volumeType == null) {
			if (other.volumeType != null) {
				return false;
			}
		} else if (!volumeType.equals(other.volumeType)) {
			return false;
		}
		return true;
	}

}
 
